package com.appengine.hotornot.utils;

import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.appengine.hotornot.Constants;

/**
 * Application config
 * 
 * @author Aliaksandr_Spichakou
 * 
 */
public class Config implements Constants{
	private static final Logger log = Logger.getLogger(Config.class
			.getName());
	private static Config instance;
	private static final String PICASA_LOGIN = "picasa.login";
	private static final String PICASA_PASSWORD = "picasa.password";
	private static final String PICASA_ALBUM_URL = "picasa.album.url";	
	
	
	private Properties config = new Properties();
	private Config() {
		try {
			config.load(getClass().getResourceAsStream(CONFIG_PATH));
		} catch (IOException e) {
			log.log(Level.SEVERE,"Cannot load config file",e);
		}
	}
	/**
	 * Get confing instance
	 * @return
	 */
	public static Config getInstance()
	{
		if(instance==null)
		{
			instance = new Config();
		}
		return instance;
	}
	
	/**
	 * Get picasa login
	 * @return
	 */
	public String getPicasaPassword()
	{
		return config.getProperty(PICASA_PASSWORD);	
	}
	/**
	 * Get picasa password
	 * @return
	 */
	public String getPicasaLogin()
	{
		return config.getProperty(PICASA_LOGIN);
	}
	
	public String getAlbumURL()
	{
		return config.getProperty(PICASA_ALBUM_URL);
	}
}
